package com.qf.controller;


import com.qf.dto.PetDto;
import com.qf.entity.Pet;
import com.qf.result.ResponseResult;
import com.qf.service.PetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/pet")
@Api(tags = "宠物管理")
public class PetController {

    @Resource
    private PetService petService;

    //获得宠物列表
    @ApiOperation(value = "获得宠物列表")
    @GetMapping("/getPetList")
    public ResponseResult getPetList(@ApiParam(value = "宠物姓名") String petName) {
        return petService.getPetList(petName);
    }

    //删除宠物信息
    @ApiOperation(value = "删除宠物信息")
    @DeleteMapping("/deletePet/{id}")
    public ResponseResult deletePet(@ApiParam(value = "宠物id", required = true, example = "1") @PathVariable("id") Integer id) {
        return petService.deletePet(id);
    }

    //修改宠物信息
    @ApiOperation(value = "修改宠物信息")
    @PutMapping("/updatePet")
    public ResponseResult updatePet(@ApiParam(value = "宠物对象", required = true) @Valid @RequestBody PetDto petDto) {
        return petService.updatePet(petDto);
    }

    //增加宠物信息
    @ApiOperation(value = "添加宠物信息")
    @PostMapping("/addPet")
    public ResponseResult addPet(@ApiParam(value = "宠物对象", required = true) @Valid @RequestBody PetDto petDto) {
        return petService.addPet(petDto);
    }

}
